package com.yenlien.traceyun.plant.dao;

import com.yenlien.traceyun.plant.entity.Soil;
import com.yenlien.traceyun.webase.dao.BaseJpaDao;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface SoilDao extends BaseJpaDao<Soil> {

    Soil findById(String id);

    @Query(value = "select * from t_plant_soil where type = 1", nativeQuery = true)
    List<Soil> findAllBase();

    @Query(value = "select * from t_plant_soil where type = ?1", nativeQuery = true)
    List<Soil> findSoilByType(String type);

    List<Soil> findByPidAndType(String pid, int type);

    @Query(value = "select * from t_plant_soil where id in (?1)", nativeQuery = true)
    List<Soil> findById(List<String> ids);

    @Query(value = "select COUNT(id) from t_base_soil where company_id in (?1) and type = ?2", nativeQuery = true)
    Long findByCompanyIdInAndType(List<String> companyId, Integer i);

    List<Soil> findByCompanyIdAndType(String companyId, Integer i);
}
